import { typing } from "./typing-console.mjs";
import readline from "readline";

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

process.stdout.clearScreenDown();

rl.pause();

function write(string) {
    return new Promise((resolve) => {
        process.stdout.write(string, resolve)
    })
}

await typing("你好!!!", write)
await write("\n");
await typing("你叫什么名字？", write)
await write("\n");
const name = await new Promise(resolve => {
    rl.setPrompt("名字：");
    rl.prompt();
    rl.once("line", resolve);
})
await write("\n");
await typing(`你好${name}！`, write)
rl.resume();
rl.close();
